from sys import stdin
input = stdin.readline
def ii():
return int(input())
def li():
return list(map(int, input().split()))
from math import sqrt
def perfect_sq(n):
x = int(sqrt(n))
while x * x < n:
x += 1
while x * x > n:
x -= 1
return (x * x == n)
for _ in range(ii()):
a,b,c,d=li()
if a*d == b*c:
print(0)
continue
if a==0 or c==0:
print(1)
continue
if (a*d) % (b*c) == 0 or (b*c) % (a*d) == 0:
print(1)
else:
print(2)
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define ld long double
using namespace std;
int gcd(int a, int b)
{
if(b == 0) return a;
return gcd(b, a%b);
}
signed main() {
int t;
cin >> t;
while(t--)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
if(a*d == b*c) { cout << 0 << endl; continue; }
int x = a*d, y = b*c;
int r = gcd(x, y);
if(r != x and r != y) cout << 2 << endl;
else cout << 1 << endl;
}
return 0;
}
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |
873D - Merge Sort | 1251A - Broken Keyboard |
463B - Caisa and Pylons | 584A - Olesya and Rodion |
799A - Carrot Cakes | 1569B - Chess Tournament |